// UI预制体管理

let uiPrefabs = function() {
    let that = {};

    that.addPrefab = (prefab)=>{
        var node = cc.instantiate(prefab);
        cc.director.getScene().getChildByName('Canvas').addChild(node);
        node.setPosition(cc.p(0, 0));
    };

    // 进入房间界面
    that.createJoinRoom = function () {
        cc.loader.loadRes("prefabs/home/JoinRoom", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 创建房间界面
    that.createRoom = function () {
        cc.loader.loadRes("prefabs/home/CreaterRoom", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    

    return that;
};

export default uiPrefabs;